/*
 * Created by JFormDesigner on Wed Apr 25 11:48:51 CEST 2012
 */

package info.rflow.ui;

import info.rflow.RFlow;
import info.rflow.Utils;
import info.rflow.graph.RWorkflowScene;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;


/**
 * @author Holger Brandl
 */
public class BirdEyeViewDialog extends JDialog {


    public BirdEyeViewDialog(RFlow owner) {
        super(owner);
        initComponents();

        setBounds(50, 500, 200, 150);
        addComponentListener(new ComponentAdapter() {
            public void componentResized(ComponentEvent e) {
                handleSizeEvent();
            }


            @Override
            public void componentMoved(ComponentEvent componentEvent) {
                handleSizeEvent();
            }


            private void handleSizeEvent() {
                Utils.saveWindowBounds("birdeye", BirdEyeViewDialog.this);
            }
        });
        Utils.restoreWindowBounds("birdeye", this);

        JPanel panel = new JPanel(new BorderLayout());
        panel.add(owner.getSesMan().getActiveWorkflow().getWorkflowScene().createSatelliteView());

        setNewView(owner.getSesMan().getActiveWorkflow().getWorkflowScene());
    }


    public void setNewView(RWorkflowScene scene) {
        getContentPane().removeAll();
        getContentPane().add(scene.createSatelliteView());
        validate();
    }


    public BirdEyeViewDialog(Dialog owner) {
        super(owner);
        initComponents();
    }


    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner non-commercial license

        //======== this ========
        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner non-commercial license
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
